<meta title="代理申请管理">
<div class="p">
    <div class="p-b">
        <form class="form-inline m-b-wrapper-xs pull-left" id="form" s="form"
              s-form="{action:function(){$page.node.val(1); $agentApplysGrid.refresh()}}"
        >
            <input autocomplete="off" type="text" class="form-control input-sm" name="phone" placeholder="会员手机号" />
            <select class="form-control input-sm"
                    name="perpetual">
                <option value="">是否永久</option>
                <option value="true">是</option>
                <option value="false">否</option>
            </select>
            <select class="form-control input-sm" s="select"
                    s-build="S.get('/api/enum/valuesMap/core.enums.AgentApplyStatus?igNames=DELETED')"
                    name="status">
                <option value="">选择状态</option>
            </select>
            <input autocomplete="off" type="hidden" name="page" id="page" value="1"/>
            <input autocomplete="off" type="submit" class="btn btn-default btn-sm" value="查找"/>
        </form>
        <div class="pull-right">
            <input autocomplete="off" type="button" s-click="add()" class="btn btn-primary btn-sm" value="新增"/>
        </div>
    </div>
    <table
            id="agentApplysGrid"
            s='datac,nda'
            s-data="Smart.cleanJsonRef(S.get('/api/agent-apply/search', $form.node.serialize()))"
            class="table table-stripped table-bordered">
        <tr>
            <th>姓名</th>
            <th>手机号</th>
            <th>区域</th>
            <th>留言</th>
            <th>创建时间</th>
            <th class="text-center">状态</th>
            <th class="text-right">操作</th>
        </tr>
        <tbody s="loop" s-data-filter="'results'">
        <tr s-loop-role="empty">
            <td colspan="7" class="alert alert-warning">
                暂无数据
            </td>
        </tr>
        <tr s-loop-role="row" s="row,datac">
            <td name="contactName"></td>
            <td name="phone"></td>
            <td name="region"></td>
            <td name="content"></td>
            <td name="createTime"></td>
            <td class="text-center" s="tpl">
                <label class="label
                            {%
                                switch(this.status) {
                                    case 'VERIFY_SUCCESS': out.print('label-success'); break;
                                    case 'VERIFY_FAIL': out.print('label-danger'); break;
                                    default: out.print('label-warning');break;
                                }
                            %}
                        ">{%=this.statusTitle%}</label>
            </td>
            <td s="tpl" class="text-right">
                {%if(this.status == 'WAIT_VERIFY') {%}
                <input autocomplete="off" type="button" s-click="verify(this, 'VERIFY_SUCCESS')" class="btn btn-xs btn-warning btn-outline" value="通过"/>
                <input autocomplete="off" type="button" s-click="verify(this, 'VERIFY_FAIL')" class="btn btn-xs btn-danger btn-outline" value="拒绝"/>
                {%} else {%}
                {%}%}
            </td>
        </tr>
        </tbody>
        <tfoot>
        <tr>
            <td colspan="7" class="text-right">
                <ul s="pagination" id="sellerPagination"
                    s-pagination="{action:function(){$page.node.val(this); $agentApplysGrid.refresh()}}"
                    class="pagination pagination-sm">
                </ul>
                共有<span name="total"></span>个数据
            </td>
        </tr>
        </tfoot>
    </table>
</div>
<script type="text/javascript">

    function verify($this, status) {
        var data = $this.parent().data();
        S.confirm("确认操作吗?").done(function() {
            S.put("/api/agent-apply/verify/" + data.id + "-" + status).done(function() {
                $agentApplysGrid.refresh()
            })
        })
    }

</script>